package com.canopys.study.open.test.designpatterns.singleton;

/**
 * @Author: Canopys
 * @Descrption:
 * @Date: Created in 22:58 2019/9/24
 * @Modified By:
 */
public class SingletonLazy {

    private static volatile SingletonLazy instance = null;

    private SingletonLazy() {}

    public static SingletonLazy getInstance() {
        if (null == instance) {
            synchronized (SingletonLazy.class) {
                if (null == instance) {
                    instance = new SingletonLazy();
                    return instance;
                } else {
                    return instance;
                }
            }
        } else {
            return instance;
        }
    }

    public void doSomething() {
        System.out.println("SingletonLazy do Something");
    }
}
